package com.greendragon.persistence.domain; 

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/** 
 * @author wulibin, exceptsky@gmail.com, 2011-9-8 下午11:07:01
 * 
 */
@Entity
@Table(name="link")
public class Link implements Serializable{
	private static final long serialVersionUID = 7010027752330271586L;

	private Long id;
	private String name;													//标题
	private String description;												//描述信息
	private String websiteUrl;												//链接地址
	private Boolean block = new Boolean(false);													//是否隐藏
	private Date createdAt;													//创建日期
	private LinkCategory category;											//所属分类
	private Resource logoImage;												//logo 图片
	private User author;													//创建者
	
	public Link(){}

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name="name", length=50)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Lob
	@Column(name="description")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name="websiteUrl", length=100)
	public String getWebsiteUrl() {
		return websiteUrl;
	}

	public void setWebsiteUrl(String websiteUrl) {
		this.websiteUrl = websiteUrl;
	}

	@ManyToOne
    @JoinColumn(name="category_id", insertable=false, updatable=false)
	public LinkCategory getCategory() {
		return category;
	}

	public void setCategory(LinkCategory category) {
		this.category = category;
	}

	@JoinColumn(name="block")
	public Boolean getBlock() {
		return block;
	}

	public void setBlock(Boolean block) {
		this.block = block;
	}

	@Column(name="createdAt")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	@ManyToOne
    @JoinColumn(name="image_id")
	public Resource getLogoImage() {
		return logoImage;
	}

	public void setLogoImage(Resource logoImage) {
		this.logoImage = logoImage;
	}

	@ManyToOne
	@JoinColumn(name="author_id")
	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

}
 